export default {
    //1GB = 1024MB,1MB = 1024KB,1KB = 1024B el-upload生成的size的大小是B
    sizetoStr: (limit) => {
        console.log(limit, "limit")
        var size = "";
        if (limit < 0.1 * 1024) { //0.1kb
            size = limit.toFixed(2) + "B"

        }
      else  if (limit < 0.1 * 1024 * 1024) {//小于0.1MB转换成kb


            size = (limit / 1024).toFixed(2) + "KB"

        }
      else  if (limit < 0.1 * 1024 * 1024 * 1024) {//小于0.1GB转换成MB


            size = (limit / (1024 * 1024)).toFixed(2) + "MB"

        } else {


            size = (limit / (1024 * 1024 * 1024)).toFixed(2) + "GB"
        }
        console.log(size, "dou")
        var sizeStr = size + "";
        var index = sizeStr.indexOf(".")
        var dou = sizeStr.substring(index + 1, 2);

        if (dou == "00") {
            console.log(dou, "dou11")

            return sizeStr.substring(0, index) + sizeStr.substr(index + 3, 2)
        }
        console.log(size, "size")
        return size;

    }
}